/**
 * @author BoLiang
 */
if (typeof accedo === "undefined") {
	accedo = {};
}
if (typeof accedo.achievement === "undefined") {
	accedo.achievement = {};
}

accedo.achievement.achiPortalFriendsSearch = {
	userName : null,
	divNumCurrID : 0,
	divFuncCurrID : 0,
	divListCurrID : 0,
	numArray : null,
	fSearchTextNode : null,
	searchText : null,
	numPress : 0,
	pressRepeated : null,
	tOut : null,
	fSearchListResultAjaxNode : null,
	fSearchListResultInner : null,
	divLength : 0,
	fSearchUpArrow : null,
	fSearchDownArrow : null,
	minTop : 0,
	maxTop : 0,
	moveCount : 0,

	init : function() {
		this.userName = null;
		this.divNumCurrID = 0; 
		this.divFuncCurrID = 0;
		this.divListCurrID = 0;
		this.fSearchTextNode = null;
		this.searchText = "";
		this.numPress = 0;
		this.tOut = null;
		this.pressRepeated = null;
		this.fSearchListResultAjaxNode = null;
		this.fSearchListResultInner = null;
		this.divLength = null;
		this.fSearchUpArrow = null;
		this.fSearchDownArrow = null;
		this.minTop = 0;
		this.maxTop = 0;
		this.moveCount = 0;
		numArray = {num:
						[
							{numValue: [ {letter:'_'}]},
							{numValue: [ {letter:'.'},{letter:'?'},{letter:'!'},{letter:','}]},
							{numValue: [ {letter:'a'},{letter:'b'},{letter:'c'}]},
							{numValue: [ {letter:'d'},{letter:'e'},{letter:'f'}]},
							{numValue: [ {letter:'g'},{letter:'h'},{letter:'i'}]},
							{numValue: [ {letter:'j'},{letter:'k'},{letter:'l'}]},
							{numValue: [ {letter:'m'},{letter:'n'},{letter:'o'}]},
							{numValue: [ {letter:'p'},{letter:'q'},{letter:'r'},{letter:'s'}]},
							{numValue: [ {letter:'t'},{letter:'u'},{letter:'v'}]},
							{numValue: [ {letter:'w'},{letter:'x'},{letter:'y'},{letter:'z'}]}
						]
					};

		document.onkeydown = function(e) {
			accedo.achievement.achiPortalFriendsSearch.numKeysControl(e);
		};
	},
	
	appendFriendsSearchDiv : function(username) {
		this.init(); 
		this.userName = username; 
		// alert(numArray.num[0].value[0].letter);
		// create friends search main container div node
		var friendsSearchMainNode = document.createElement("div"); 
		friendsSearchMainNode.id = "friendsSearchMain"; 

		// append the search list node into friends search main container
		friendsSearchMainNode.appendChild(this.createSearchList());

		// append the keyboard node into friends search main container
		friendsSearchMainNode.appendChild(this.createKeyboard());
		return friendsSearchMainNode;
	},

	createSearchList : function() {
		// create search list container node
		var fSearchListCtn = document.createElement("div");
		fSearchListCtn.id = "fSearchListCtn";

		// create search lable
		var fSearchLable = document.createElement("div");
		fSearchLable.id = "fSearchLable";
		fSearchLable.innerHTML = "<font color=white>Enter Friend's Name :</font>";

		// create text area node
		this.fSearchTextNode = document.createElement("div");
		this.fSearchTextNode.id = "fSearchText";

		// create list result ajax container node
		this.fSearchListResultAjaxNode = document.createElement("div");
		this.fSearchListResultAjaxNode.id = "fSearchListResultAjax";

		fSearchListCtn.appendChild(fSearchLable);
		fSearchListCtn.appendChild(this.fSearchTextNode);
		fSearchListCtn.appendChild(this.fSearchListResultAjaxNode);

		return fSearchListCtn; 
	},

	createKeyboard : function() {	
		// create keyboard container div node
		var fSearchKeyboardCtn = document.createElement("div");
		fSearchKeyboardCtn.id = "fSearchKeyboardCtn";

		// append the functionality keys container node into keyboard container div node
		fSearchKeyboardCtn.appendChild(this.createFuncKeys()); 

		// append the number keys container node into keyboard container div node
		for (var rowNum = 0; rowNum < 4; rowNum++) {
			fSearchKeyboardCtn.appendChild(this.createNumKeys(rowNum));
		}		

		

		return fSearchKeyboardCtn;
	},

	createFuncKeys : function() {
		// create functionality keyboard row container node
		var keyboardRowNode = document.createElement("div");
		keyboardRowNode.id = "keyboardFuncRow";

		for (var keyNum = 1; keyNum <= 4; keyNum++) {
			var funcKey = document.createElement("div");
			funcKey.id = "funcKey" + keyNum;
			funcKey.className = "funcKey";
			funcKey.style.left = 13 * (keyNum - 1) + "px";
			funcKey.innerHTML = "<img width=100% height=100% src='http://"
							+ accedo.achievement.config.serverIP + ":" 
							+ accedo.achievement.config.serverPort + "/" 
							+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
							+ "fb" + keyNum + ".png' />"; 

			keyboardRowNode.appendChild(funcKey);
		}

		return keyboardRowNode;

	},

	createNumKeys : function(rowNum) {
		// create number keyboard row container node
		var keyboardRowNode = document.createElement("div");
		keyboardRowNode.id = "keyboardNumRow";
		keyboardRowNode.style.top = 13 * (rowNum + 1) + "px";

		// append num 0 in the last row
		if (rowNum == 3) {
			var numKey = document.createElement("div");
			numKey.id = "numKey0";
			numKey.className = "numKey"; 
			numKey.style.left = 163 + 13 + "px";
			numKey.innerHTML = "<img width=100% height=100% src='http://"
							+ accedo.achievement.config.serverIP + ":" 
							+ accedo.achievement.config.serverPort + "/" 
							+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
							+ "b0.png' />"; 

			keyboardRowNode.appendChild(numKey);

		// append num 1-9
		} else {
			for(var keyNum = 0; keyNum < 3; keyNum++) {
				var numKey = document.createElement("div");
				numKey.id = "numKey" + ((rowNum * 3 + 1) + keyNum);
				numKey.className = "numKey"; 
				numKey.style.left = 13 * keyNum + "px";
				numKey.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "b" + ((rowNum * 3 + 1) + keyNum) + ".png' />"; 

				keyboardRowNode.appendChild(numKey);
			}
		}

		return keyboardRowNode;
	},

	moveCurrDiv : function(direction) {
		var divOldNode = document.getElementById("numKey" + this.divNumCurrID);
		divOldNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "b" + this.divNumCurrID  + ".png' />"; 
		if (this.tOut != null) {
			clearTimeout(this.tOut);
		}
		
		if (direction == "right") {
			this.pressRepeated = false;
			this.numPress = 0;
			if (this.divNumCurrID == 9) {
				this.divNumCurrID = 0;
			} else {
				this.divNumCurrID = this.divNumCurrID + 1;
			
			}
		
		} else if (direction == "left") {
			this.pressRepeated = false;
			this.numPress = 0;

			// if friends search list has at least one result
			var firstSearchResult = document.getElementById("fSearchCell0");
			if (firstSearchResult) {
				if (this.divNumCurrID == 0 || this.divNumCurrID == 1 || this.divNumCurrID == 4 || this.divNumCurrID == 7) {
					document.onkeydown = function(e) {
						accedo.achievement.achiPortalFriendsSearch.resultListKeysControl(e);
					};
					var CurrAddButton = document.getElementById("fSearchAddButton" + this.divListCurrID);
					CurrAddButton.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/f_add.png' />";
					return;
				} else {
					this.divNumCurrID = this.divNumCurrID - 1;
				}
			} else {
				if (this.divNumCurrID == 0) {
					this.divNumCurrID = 9;
				} else {
					this.divNumCurrID = this.divNumCurrID - 1;
				}
			}
			

		} else if (direction == "down") {
			this.pressRepeated = false;
			this.numPress = 0;
			this.divNumCurrID = this.divNumCurrID + 3;
			if (this.divNumCurrID > 9 && this.divNumCurrID != 11) {
				this.divNumCurrID = this.divNumCurrID - 9;
			// 8 -> 0
			} else if (this.divNumCurrID == 11) {
				this.divNumCurrID = 0;
			// 0 -> 2
			} else if (this.divNumCurrID == 3) {
				this.divNumCurrID = 2;
			}

		} else if (direction == "up") {
			this.pressRepeated = false;
			this.numPress = 0;
			this.divNumCurrID = this.divNumCurrID - 3;
			if (this.divNumCurrID <= 0 && this.divNumCurrID != -3 && this.divNumCurrID != -2 && this.divNumCurrID != -1 && this.divNumCurrID != 0) {
				this.divNumCurrID = this.divNumCurrID + 9;
			// 0 -> 8
			} else if (this.divNumCurrID == -3) {
				this.divNumCurrID = 8;
			
			// 1 2 3 -> functionality keys
			} else if (this.divNumCurrID == -2 || this.divNumCurrID == -1 || this.divNumCurrID == 0) {
				this.divFuncCurrID = this.divNumCurrID + 3;
				var divNewNode = document.getElementById("funcKey" + this.divFuncCurrID);
				divNewNode.innerHTML = "<img width=100% height=100% src='http://"
									+ accedo.achievement.config.serverIP + ":" 
									+ accedo.achievement.config.serverPort + "/" 
									+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
									+ "f_fb" + this.divFuncCurrID + ".png' />"; 
				document.onkeydown = function(e) {
					accedo.achievement.achiPortalFriendsSearch.funcKeysControl(e);
				};
				return;
			} 

		} else if (direction == "enter") {
			

			if (this.pressRepeated == true) {
				this.searchText = this.searchText.substr(0,this.searchText.length - 1);
			}
			
			this.searchText = this.searchText + numArray.num[this.divNumCurrID].numValue[this.numPress].letter;
			this.fSearchTextNode.innerHTML = "<font color=black>" + this.searchText + "</font>";

			this.numPress++;
			
			if (this.numPress > numArray.num[this.divNumCurrID].numValue.length - 1) {
				this.numPress = 0;
			}

			this.pressRepeated = true;
			this.tOut = setTimeout(
				function() {
					accedo.achievement.achiPortalFriendsSearch.pressRepeated = false;
					accedo.achievement.achiPortalFriendsSearch.numPress = 0;
					accedo.achievement.achiPortalFriendsSearch.initSearchResult(
						accedo.achievement.achiPortalFriendsSearch.userName,
						accedo.achievement.achiPortalFriendsSearch.searchText);

				},
				2000
			);

		} else if (direction == "return") {
			document.onkeydown = function(e) {
				accedo.achievement.achiPortalShow.titleKeysControl(e);
			};
			var newSocialButton = document.getElementById("social" + accedo.achievement.achiPortalShow.divTitleCurrID);
			newSocialButton.style.borderColor = "yellow";
			return;
		}

		var divNewNode = document.getElementById("numKey" + this.divNumCurrID);
		divNewNode.innerHTML = "<img width=100% height=100% src='http://"
							+ accedo.achievement.config.serverIP + ":" 
							+ accedo.achievement.config.serverPort + "/" 
							+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
							+ "f_b" + this.divNumCurrID + ".png' />"; 
	},

	initSearchResult : function(username, inputString) {
			dwr.engine.setPreHook(this.preHook); 
			dwr.engine.setPostHook(this.postHook); 
			this.cleanSearchResult();
			UserService._path = "http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/dwr";
			UserService.getJsonNoneFriendsByInputString(username, inputString, this.initSearchResultCallback);
		},
	cleanSearchResult : function() {
		var resultCtn = document.getElementById("fSearchResultListCtn");
		// alert(resultCtn.nodeName); 
		if (resultCtn) {
			this.fSearchListResultAjaxNode.removeChild(resultCtn);
		}
	},
	preHook : function() {
		var loadingNode = document.createElement("div");
		loadingNode.id = "loadingNode";
		loadingNode.className = "fSearchLoadingNode";
		loadingNode.innerHTML = "<br /><br /><img width=100px height=100px src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/images/otherImages/loading.gif' />"; 
		accedo.achievement.achiPortalFriendsSearch.fSearchListResultAjaxNode.appendChild(loadingNode);
	},
	postHook : function() {
		var loadingNode = document.getElementById("loadingNode");
		accedo.achievement.achiPortalFriendsSearch.fSearchListResultAjaxNode.removeChild(loadingNode);

	},
		
	initSearchResultCallback : function(data) {
		var serverDataObj = eval("(" + data + ")");
		accedo.achievement.achiPortalFriendsSearch.fSearchListResultAjaxNode.appendChild(
			accedo.achievement.achiPortalFriendsSearch.createSearchResultNode(serverDataObj));

	},

	createSearchResultNode : function(serverDataObj) {
		// create container
		var fSearchResultListCtn = document.createElement("div");
		fSearchResultListCtn.id = "fSearchResultListCtn";

		// create up arrow node
		this.fSearchUpArrow = document.createElement("div"); 
		this.fSearchUpArrow.id = "fSearchListResultArrow"; 
		this.fSearchUpArrow.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/upArrow.png' />";
		this.fSearchUpArrow.style.visibility = "hidden";
		this.fSearchDownArrow = document.createElement("div");
		this.fSearchDownArrow.id = "fSearchListResultArrow";
		this.fSearchDownArrow.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/downArrow.png' />";


		// create search list result container node
		var fSearchListResultCtn = document.createElement("div");
		fSearchListResultCtn.id = "fSearchListResultCtn";
		fSearchListResultCtn.appendChild(this.createSearchResultInnerNode(serverDataObj));

		fSearchResultListCtn.appendChild(this.fSearchUpArrow);
		fSearchResultListCtn.appendChild(fSearchListResultCtn);
		fSearchResultListCtn.appendChild(this.fSearchDownArrow);

		return fSearchResultListCtn;
		
	},

	createSearchResultInnerNode : function(serverDataObj){
		this.divLength = serverDataObj.friends.length;

		this.minTop = 300 - (this.divLength * 100);
		this.maxTop = 0;
		if (this.minTop >= 0) {
			this.fSearchDownArrow.style.visibility = "hidden";
		}



		// create inner node
		this.fSearchListResultInner = document.createElement("div");
		this.fSearchListResultInner.id = "fSearchListResultInner"; 
		this.fSearchListResultInner.style.height = (this.divLength * 100) + "px";

		for (var divNum = 0; divNum < this.divLength; divNum++) {
			var fSearchCell = document.createElement("div");
			fSearchCell.id = "fSearchCell" + divNum;
			fSearchCell.className = "fSearchCell";
			

			// create avatar node
			var avatarNode = document.createElement("div");
			avatarNode.id = "fSearchAvatar";
			avatarNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/images/userImages/user"
								+ serverDataObj.friends[divNum].friend_id + ".png' />";

			// create friend info node
			var friendInfoNode = document.createElement("div");
			friendInfoNode.id = "fSearchFriendInfo";
			friendInfoNode.innerHTML="<font color=white>"
								+ serverDataObj.friends[divNum].friend_name
								+ "</font>";

			// create add button node
			var addButton = document.createElement("div");
			addButton.id = "fSearchAddButton" + divNum;
			addButton.className = "fSearchAddButton";
			addButton.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/add.png' />";

			fSearchCell.appendChild(avatarNode);
			fSearchCell.appendChild(friendInfoNode);
			fSearchCell.appendChild(addButton);
			var fSearchInterval = document.createElement("div");
			fSearchInterval.id = "fSearchInterval";
			fSearchInterval.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/rInterval.png' />";
			this.fSearchListResultInner.appendChild(fSearchCell);
			this.fSearchListResultInner.appendChild(fSearchInterval);
		}


		return this.fSearchListResultInner;
	},


	numKeysControl : function(e) {
		e = window.event || e;
		switch (e.keyCode) {
		// up button
		case 37:
			this.moveCurrDiv("left");
			break;	
		// up button
		case 38:
			this.moveCurrDiv("up");
			break;
		// right button
		case 39:
			this.moveCurrDiv("right");
			break;
		// down button
		case 40:
			this.moveCurrDiv("down");
			break; 
		// enter button
		case 13:
			this.moveCurrDiv("enter");
			break;
		// esc button
		case 27:
			this.moveCurrDiv("return");
			break;
		default:
			break;
		}
	},

	resultListKeysControl : function(e) {
		e = window.event || e;
		switch (e.keyCode) {

		// up button
		case 38:
			this.resultListMoveCurrDiv("up");
			break;
		// right button
		case 39:
			this.resultListMoveCurrDiv("right");
			break;
		// down button
		case 40:
			this.resultListMoveCurrDiv("down");
			break; 
		// enter button
		case 13:
			this.resultListMoveCurrDiv("enter");
			break;
		default:
			break;
		}
	},

	resultListMoveCurrDiv : function(direction) {
		var oldAddButton = document.getElementById("fSearchAddButton" + this.divListCurrID);
		oldAddButton.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/add.png' />";
		if(direction == "up" && this.divListCurrID > 0) {
			this.divListCurrID--;

			if (this.moveCount == 0) {
				var topValue = this.fSearchListResultInner.offsetTop + 100;
				this.fSearchListResultInner.style.top = topValue + "px";
					
					if (topValue >= this.maxTop) {
						this.fSearchUpArrow.style.visibility = "hidden"; 
					}
					
					if (topValue > this.minTop) {
						this.fSearchDownArrow.style.visibility = "visible"; 
					}
			} else {
				this.moveCount--;
			}
			

		} else if(direction == "down" && this.divListCurrID < this.divLength - 1) {
			this.divListCurrID++;

			if (this.moveCount == 2) {
				var topValue = this.fSearchListResultInner.offsetTop - 100;
				this.fSearchListResultInner.style.top = topValue + "px";
					
					if (topValue <= this.minTop) {
						this.fSearchDownArrow.style.visibility = "hidden"; 
					}
					
					if (topValue < this.maxTop) {
						this.fSearchUpArrow.style.visibility = "visible"; 
					}
			} else {
				this.moveCount++;
			}

		} else if (direction == "right") {
			document.onkeydown = function(e) {
					accedo.achievement.achiPortalFriendsSearch.numKeysControl(e);
			};

			var currNumNode = document.getElementById("numKey" + this.divNumCurrID);
			currNumNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "f_b" + this.divNumCurrID  + ".png' />"; 
			return;

		}



		var newAddButton = document.getElementById("fSearchAddButton" + this.divListCurrID);
		newAddButton.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/f_add.png' />";

	},


	funcKeysControl : function(e) {
		e = window.event || e;
		switch (e.keyCode) {
		// up button
		case 37:
			// this.moveCurrDiv("left");
			var divOldNode = document.getElementById("funcKey" + this.divFuncCurrID);
			divOldNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "fb" + this.divFuncCurrID  + ".png' />"; 

			this.divFuncCurrID = this.divFuncCurrID - 1;
			if (this.divFuncCurrID == 0) {
				this.divFuncCurrID = 4;
			}
			var divNewNode = document.getElementById("funcKey" + this.divFuncCurrID);
			divNewNode.innerHTML = "<img width=100% height=100% src='http://"
							+ accedo.achievement.config.serverIP + ":" 
							+ accedo.achievement.config.serverPort + "/" 
							+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
							+ "f_fb" + this.divFuncCurrID + ".png' />"; 

			break;	
		// right button
		case 39:
			var divOldNode = document.getElementById("funcKey" + this.divFuncCurrID);
			divOldNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "fb" + this.divFuncCurrID  + ".png' />"; 

			this.divFuncCurrID = this.divFuncCurrID + 1;
			if (this.divFuncCurrID == 5) {
				this.divFuncCurrID = 1;
			}
			var divNewNode = document.getElementById("funcKey" + this.divFuncCurrID);
			divNewNode.innerHTML = "<img width=100% height=100% src='http://"
							+ accedo.achievement.config.serverIP + ":" 
							+ accedo.achievement.config.serverPort + "/" 
							+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
							+ "f_fb" + this.divFuncCurrID + ".png' />"; 
			break;
		// down button
		case 40:
		if (this.tOut != null) {
			clearTimeout(this.tOut);
		}
			var divOldNode = document.getElementById("funcKey" + this.divFuncCurrID);
			divOldNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "fb" + this.divFuncCurrID  + ".png' />"; 

			if (this.divFuncCurrID == 4) {
				this.divNumCurrID = 3;
			} else {
				this.divNumCurrID = this.divFuncCurrID;
			}
			var divNewNode = document.getElementById("numKey" + this.divNumCurrID);
			divNewNode.innerHTML = "<img width=100% height=100% src='http://"
								+ accedo.achievement.config.serverIP + ":" 
								+ accedo.achievement.config.serverPort + "/" 
								+ accedo.achievement.config.pluginName + "/achiPortal/images/keyboard/" 
								+ "f_b" + this.divNumCurrID + ".png' />";
			document.onkeydown = function(e) {
				accedo.achievement.achiPortalFriendsSearch.numKeysControl(e);
			};
			break; 
		// enter button
		case 13:
		if (this.tOut != null) {
			clearTimeout(this.tOut);
		}
			if (this.divFuncCurrID == 4 && this.searchText.length > 0) {
				this.searchText = this.searchText.substr(0,this.searchText.length - 1);
				this.fSearchTextNode.innerHTML = "<font color=black>" + this.searchText + "</font>";
				
				if (this.searchText.length > 0) {
					this.tOut = setTimeout(
						function() {
							accedo.achievement.achiPortalFriendsSearch.pressRepeated = false;
							accedo.achievement.achiPortalFriendsSearch.numPress = 0;
							accedo.achievement.achiPortalFriendsSearch.initSearchResult(
								accedo.achievement.achiPortalFriendsSearch.userName,
								accedo.achievement.achiPortalFriendsSearch.searchText);

						},
						2000
					);
				}	
			}
			break;
		default:
			break;
		}
	}

};